/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.admin.controller;

import com.admin.model.EventLibraryFacadeLocal;
import com.common.json.JsonModel;
import com.entities.EventLibrary;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;

/**
 *
 * @author Tuan Long
 */
@Stateless
public class UpdateEventEJB implements UpdateEventEJBRemote {
    @EJB
    private EventLibraryFacadeLocal eventLibraryFacade;    
    /**
     *@UpdateEventEJB.updateEvent : update an event record in EventLibrary table by EventId(Primary key)
     * @param jsonstr     
     * @return boolean      
     */
    @Override
    public boolean updateEvent(String jsonstr) {
        try {
            JSONObject json = JsonModel.JsonDecoder(jsonstr);            
            EventLibrary obj = JsonModel.eventMessageReader(json);                      
            eventLibraryFacade.edit(obj); 
            return true;
        } catch (Exception e) {                       
            System.out.println(e.getMessage());
            return false;            
        }
    }

    
}
